package com.itheima.controller;

import com.itheima.entity.EmpQueryParam;
import com.itheima.entity.PageBean;
import com.itheima.entity.Result;
import com.itheima.mapper.EmpMapper;
import com.itheima.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@Slf4j
@RequestMapping("/emps")
@RestController
public class EmpController {
    @Autowired
    private EmpService empService;

    @GetMapping
    public Result page(/*@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer pageSize,
                       String name, Integer gender,
                       @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate begin,
                       @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate end*/
    EmpQueryParam empQueryParam
    ) {
//        log.info("分页查询员工信息，当前页码：{}，每页记录数：{}", page, pageSize);
//        log.info("员工姓名：{}，员工性别：{}，开始日期：{}，结束日期：{}", name, gender, begin, end);
//        PageBean pageBean = empService.page(page, pageSize);
        log.info("员工查询参数：{}", empQueryParam);
//        PageBean pageBean = null;
        PageBean pageBean = empService.page(empQueryParam);
        return Result.success(pageBean);
    }
}
